﻿using System;
using Tao.OpenGl;

namespace GLWrap.SceneObjects
{
    public class GluQuadricObject : IDisposable 
    {
        private readonly Glu.GLUquadric _quadric;

        public Glu.GLUquadric Quadric
        {
            get
            {
                if(_disposed) throw new ObjectDisposedException("Object already disposed");
                return _quadric;
            }
        }
        
        private bool _disposed;

        public GluQuadricObject()
        {
            _quadric = Glu.gluNewQuadric();
        }

        public void Dispose()
        {
            if (!_disposed)
            {
                Glu.gluDeleteQuadric(Quadric);
                _disposed = true;
            }
        }
    }
}
